<template>
	<view>
		<textarea placeholder="请输入内容" v-model="inputText"></textarea>
		<button @tap="submit">提交</button>
	</view>
</template>

<script>
	import http from '/pages/utils/request.js'
	import {useUserInfoStore} from '/pages/stores/userInfo.js'
	const userStore = useUserInfoStore()
	export default {
		data() {
			return {
				inputText: '',
				
				commentDTO:{
					bookId:0,
					comment:'',
					commentUserId:1,
					commentUserAvatar:'https://img.zcool.cn/community/031sxqxmbh8v1ymr99gtldt3535.png',
					commentUserName:'',
				},
			}
		},
		onLoad(option) {
			this.commentDTO.bookId=option.bookid
		},
		methods: {
			submit(){
				
				this.commentDTO.commentUserName=userStore.info.username
				this.commentDTO.comment=this.inputText
				http.post("/user/comment",this.commentDTO,{headers:{"Content-Type":"application/json"}}).then(res => {
					alert('评论成功')
					uni.navigateBack({
					      delta: 1,
					    });
					console.log(res.data);
				})
				
			}
		}
	}
</script>

<style>
	textarea{
		background-color: whitesmoke;
		width: 750rpx;
	}
</style>
